using FadeLang.Ast;
using FadeLang.Runtime;

namespace FadeLang.CstVisitor
{
    internal class ChunkVisitor : FadeLangBaseVisitor<Chunk>
    {
        private readonly Context context;

        public ChunkVisitor(Context context) {
            this.context = context;
        }


        public override Chunk VisitChunk(FadeLangParser.ChunkContext context) {
            var chunk = new Chunk();
            foreach (var blockContext in context.block()) {
                chunk.Blocks.Add(blockContext.Accept(new BlockVisitor(this.context)));
            }
            return chunk;
        }
    }
}